﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;
using blackhouse.WebNemo.Business.Groups;

namespace blackhouse.WebNemo.Web.Controls {
	public class OneDisplayRecordValue : DisplayRecordValue {

		#region Fields

		private HyperLink display;

		#endregion

		#region Properties

		private HyperLink DisplayControl {
			get {
				if (this.display == null) {
					this.display = new HyperLink();
					this.Controls.Add(this.display);
				}
				return display;
			}
		}

		#endregion

		#region Methods

		protected override void PopulateControl() {
			GroupRecord refRecord = this.record.GetRecord(this.column.ColumnName);
			this.DisplayControl.Text = refRecord.Identyficator + "<span></span>";
			this.DisplayControl.CssClass = "record-ref";
			this.DisplayControl.ToolTip = "Pokaż cały rekord";
            NemoUrl url = NemoUrl.Get();
            url.GroupId = refRecord.BelongsToGroupId;
            url.RecordId = refRecord.RecordId;
            url.View = NemoUrlView.Preview;
            this.DisplayControl.NavigateUrl = url.GetUrl();
		}

		#endregion
		 
	}
}